Browse Source

Reorganize the repository for new build system

pull/14/head
Rafal Kupiec 4 years ago
parent
commit
abb91a9874
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
  1. 165
      Makefile
  2. 111
      Makefile.new
  3. 0
      engine/api.c
  4. 0
      engine/builtin.c
  5. 0
      engine/compiler.c
  6. 0
      engine/constant.c
  7. 0
      engine/hashmap.c
  8. 0
      engine/lexer.c
  9. 0
      engine/lib/lib.c
  10. 0
      engine/memobj.c
  11. 0
      engine/oop.c
  12. 0
      engine/parser.c
  13. 0
      engine/vfs.c
  14. 0
      engine/vm.c
  15. 0
      include/ph7.h
  16. 0
      include/ph7int.h
  17. 0
      modules/dummy/dummy.c
  18. 0
      modules/dummy/dummy.h
  19. 0
      modules/json/json.c
  20. 0
      modules/json/json.h
  21. 0
      modules/xml/lib.c
  22. 0
      modules/xml/lib.h
  23. 0
      modules/xml/xml.c
  24. 0
      modules/xml/xml.h
  25. 0
      sapi/cli/main.c

165
Makefile

@ -1,68 +1,111 @@
CFLAGS = -W -Wunused -Wall -I. -g -o -Ofast -DPH7_ENABLE_MATH_FUNC
LDFLAGS = -Wl,--export-dynamic -ldl -lm -rdynamic
CC = gcc
INCLUDES =
ENGINE_OBJS =\
api.o \
builtin.o \
compile.o \
constant.o \
hashmap.o \
interpreter.o \
lexer.o \
lib.o \
memobj.o \
oop.o \
parser.o \
vfs.o \
vm.o
ASTYLE_FLAGS =\
--style=java \
--indent=force-tab \
--attach-closing-while \
--attach-inlines \
--attach-classes \
--indent-classes \
--indent-modifiers \
--indent-switches \
--indent-cases \
--indent-preproc-block \
--indent-preproc-define \
--indent-col1-comments \
--pad-oper \
--pad-comma \
--unpad-paren \
--delete-empty-lines \
--align-pointer=name \
--align-reference=name \
--break-one-line-headers \
--add-braces \
--verbose \
--formatted \
--lineend=linux
all: psharp dummy.lib json.lib xml.lib
# Flags to pass to the compiler
CFLAGS = -fPIC -Iinclude -I. -W -Wunused -Wall
clean:
rm -f psharp $(ENGINE_OBJS) *.lib
# Additional CFLAGS for debug build
DFLAGS = -O0 -g
# Addditional CFLAGS for release build
RFLAGS = -O3 -s
# Flags to pass to the linker
LFLAGS = -Wl,--export-dynamic -rdynamic
# Additional libraries necessary for linker
LIBS = -ldl -lm
##############################################
### Do not modify anything below this line ###
##############################################
ifeq ($(OS),Windows_NT)
PLATFORM := "Windows"
else
PLATFORM := $(shell uname -s)
endif
ifeq "$(PLATFORM)" "Darwin"
CC := clang
MD := mkdir -p
RM := rm -rfv
ESUFFIX :=
LSUFFIX := .dylib
endif
ifeq "$(PLATFORM)" "FreeBSD"
CC := clang
MD := mkdir -p
RM := rm -rfv
ESUFFIX :=
LSUFFIX := .so
endif
ifeq "$(PLATFORM)" "Linux"
CC := gcc
MD := mkdir -p
RM := rm -rfv
ESUFFIX :=
LSUFFIX := .so
endif
ifeq "$(PLATFORM)" "OpenBSD"
CC := clang
MD := mkdir -p
RM := rm -rfv
ESUFFIX :=
LSUFFIX := .so
endif
ifeq "$(PLATFORM)" "Windows"
CC := gcc
MD := md
RM := del /F
ESUFFIX := .exe
LSUFFIX := .dll
endif
BINARY := psharp
BUILD_DIR := build
CFLAGS := $(CFLAGS) -DPH7_LIBRARY_SUFFIX=$(LSUFFIX)
style:
astyle $(ASTYLE_FLAGS) --recursive ./*.c,*.h
ENGINE_DIRS := engine/lib engine
ENGINE_SRCS := $(foreach dir,$(ENGINE_DIRS),$(wildcard $(dir)/*.c))
ENGINE_MAKE := $(ENGINE_SRCS:.c=.o)
ENGINE_OBJS := $(addprefix $(BUILD_DIR)/,$(ENGINE_MAKE))
psharp: $(ENGINE_OBJS)
$(CC) -o psharp $(LDFLAGS) $^
MODULE := $(subst /,,$(subst modules/,,$(dir $(wildcard modules/*/))))
SAPI := $(subst /,,$(subst sapi/,,$(dir $(wildcard sapi/*/))))
%.o: %.c
$(CC) -c $(INCLUDES) $(CFLAGS) -o $@ -c $<
dummy.lib: ext/dummy/dummy.c
$(CC) $(CFLAGS) $(LDFLAGS) -shared -fPIC -o dummy.lib ext/dummy/dummy.c
.SUFFIXES:
.PHONY: clean debug release style test
json.lib: ext/json/json.c
$(CC) $(CFLAGS) $(LDFLAGS) -shared -fPIC -o json.lib ext/json/json.c
debug: export CFLAGS := $(CFLAGS) $(DFLAGS)
debug: engine sapi module
release: export CFLAGS := $(CFLAGS) $(RFLAGS)
release: engine sapi module
xml.lib: ext/xml/xml.c
$(CC) $(CFLAGS) $(LDFLAGS) -shared -fPIC -o xml.lib ext/xml/lib.c ext/xml/xml.c
engine: $(ENGINE_OBJS)
module: $(MODULE)
sapi: $(SAPI)
$(BUILD_DIR)/%.o: %.c
$(MD) $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
$(MODULE):
$(eval MODULE_DIRS := $@)
$(eval MODULE_SRCS := $(foreach dir,modules/$(MODULE_DIRS),$(wildcard $(dir)/*.c)))
$(eval MODULE_MAKE := $(MODULE_SRCS:.c=.o))
$(eval MODULE_OBJS := $(addprefix $(BUILD_DIR)/,$(MODULE_MAKE)))
$(eval MODULE_PROG := $(MODULE_DIRS)$(LSUFFIX))
$(MAKE) $(MODULE_OBJS)
$(CC) -o $(BUILD_DIR)/$(MODULE_PROG) $(LFLAGS) $(LIBS) -shared $(MODULE_OBJS)
$(SAPI):
$(eval SAPI_DIRS := $@)
$(eval SAPI_SRCS := $(foreach dir,sapi/$(SAPI_DIRS),$(wildcard $(dir)/*.c)))
$(eval SAPI_MAKE := $(SAPI_SRCS:.c=.o))
$(eval SAPI_OBJS := $(addprefix $(BUILD_DIR)/,$(SAPI_MAKE)))
$(eval SAPI_PROG := $(subst -cli,,$(BINARY)-$(SAPI_DIRS))$(ESUFFIX))
$(MAKE) $(SAPI_OBJS)
$(CC) -o $(BUILD_DIR)/$(SAPI_PROG) $(LFLAGS) $(LIBS) $(ENGINE_OBJS) $(SAPI_OBJS)
clean:
$(RM) $(BUILD_DIR)

111
Makefile.new

@ -1,111 +0,0 @@
# Flags to pass to the compiler
CFLAGS = -fPIC -Iinclude -I. -W -Wunused -Wall
# Additional CFLAGS for debug build
DFLAGS = -O0 -g
# Addditional CFLAGS for release build
RFLAGS = -O3 -s
# Flags to pass to the linker
LFLAGS = -Wl,--export-dynamic -rdynamic
# Additional libraries necessary for linker
LIBS = -ldl -lm
##############################################
### Do not modify anything below this line ###
##############################################
ifeq ($(OS),Windows_NT)
PLATFORM := "Windows"
else
PLATFORM := $(shell uname -s)
endif
ifeq "$(PLATFORM)" "Darwin"
CC := clang
MD := mkdir -p
RM := rm -rfv
ESUFFIX :=
LSUFFIX := .dylib
endif
ifeq "$(PLATFORM)" "FreeBSD"
CC := clang
MD := mkdir -p
RM := rm -rfv
ESUFFIX :=
LSUFFIX := .so
endif
ifeq "$(PLATFORM)" "Linux"
CC := gcc
MD := mkdir -p
RM := rm -rfv
ESUFFIX :=
LSUFFIX := .so
endif
ifeq "$(PLATFORM)" "OpenBSD"
CC := clang
MD := mkdir -p
RM := rm -rfv
ESUFFIX :=
LSUFFIX := .so
endif
ifeq "$(PLATFORM)" "Windows"
CC := gcc
MD := md
RM := del /F
ESUFFIX := .exe
LSUFFIX := .dll
endif
BINARY := psharp
BUILD_DIR := build
CFLAGS := $(CFLAGS) -DPH7_LIBRARY_SUFFIX=$(LSUFFIX)
ENGINE_DIRS := engine/lib engine
ENGINE_SRCS := $(foreach dir,$(ENGINE_DIRS),$(wildcard $(dir)/*.c))
ENGINE_MAKE := $(ENGINE_SRCS:.c=.o)
ENGINE_OBJS := $(addprefix $(BUILD_DIR)/,$(ENGINE_MAKE))
MODULE := $(subst /,,$(subst modules/,,$(dir $(wildcard modules/*/))))
SAPI := $(subst /,,$(subst sapi/,,$(dir $(wildcard sapi/*/))))
.SUFFIXES:
.PHONY: clean debug release style test
debug: export CFLAGS := $(CFLAGS) $(DFLAGS)
debug: engine sapi module
release: export CFLAGS := $(CFLAGS) $(RFLAGS)
release: engine sapi module
engine: $(ENGINE_OBJS)
module: $(MODULE)
sapi: $(SAPI)
$(BUILD_DIR)/%.o: %.c
$(MD) $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
$(MODULE):
$(eval MODULE_DIRS := $@)
$(eval MODULE_SRCS := $(foreach dir,modules/$(MODULE_DIRS),$(wildcard $(dir)/*.c)))
$(eval MODULE_MAKE := $(MODULE_SRCS:.c=.o))
$(eval MODULE_OBJS := $(addprefix $(BUILD_DIR)/,$(MODULE_MAKE)))
$(eval MODULE_PROG := $(MODULE_DIRS)$(LSUFFIX))
$(MAKE) $(MODULE_OBJS)
$(CC) -o $(BUILD_DIR)/$(MODULE_PROG) $(LFLAGS) $(LIBS) -shared $(MODULE_OBJS)
$(SAPI):
$(eval SAPI_DIRS := $@)
$(eval SAPI_SRCS := $(foreach dir,sapi/$(SAPI_DIRS),$(wildcard $(dir)/*.c)))
$(eval SAPI_MAKE := $(SAPI_SRCS:.c=.o))
$(eval SAPI_OBJS := $(addprefix $(BUILD_DIR)/,$(SAPI_MAKE)))
$(eval SAPI_PROG := $(subst -cli,,$(BINARY)-$(SAPI_DIRS))$(ESUFFIX))
$(MAKE) $(SAPI_OBJS)
$(CC) -o $(BUILD_DIR)/$(SAPI_PROG) $(LFLAGS) $(LIBS) $(ENGINE_OBJS) $(SAPI_OBJS)
clean:
$(RM) $(BUILD_DIR)

0
api.c → engine/api.c

0
builtin.c → engine/builtin.c

0
compile.c → engine/compiler.c

0
constant.c → engine/constant.c

0
hashmap.c → engine/hashmap.c

0
lexer.c → engine/lexer.c

0
lib.c → engine/lib/lib.c

0
memobj.c → engine/memobj.c

0
oop.c → engine/oop.c

0
parser.c → engine/parser.c

0
vfs.c → engine/vfs.c

0
vm.c → engine/vm.c

0
ph7.h → include/ph7.h

0
ph7int.h → include/ph7int.h

0
ext/dummy/dummy.c → modules/dummy/dummy.c

0
ext/dummy/dummy.h → modules/dummy/dummy.h

0
ext/json/json.c → modules/json/json.c

0
ext/json/json.h → modules/json/json.h

0
ext/xml/lib.c → modules/xml/lib.c

0
ext/xml/lib.h → modules/xml/lib.h

0
ext/xml/xml.c → modules/xml/xml.c

0
ext/xml/xml.h → modules/xml/xml.h

0
interpreter.c → sapi/cli/main.c

Loading…
Cancel
Save