Browse Source

Reorganize the repository for new build system

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

+ 104
- 61
Makefile View File

@ -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)

+ 0
- 111
Makefile.new View File

@ -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)

api.c → engine/api.c View File


builtin.c → engine/builtin.c View File


compile.c → engine/compiler.c View File


constant.c → engine/constant.c View File


hashmap.c → engine/hashmap.c View File


lexer.c → engine/lexer.c View File


lib.c → engine/lib/lib.c View File


memobj.c → engine/memobj.c View File


oop.c → engine/oop.c View File


parser.c → engine/parser.c View File


vfs.c → engine/vfs.c View File


vm.c → engine/vm.c View File


ph7.h → include/ph7.h View File


ph7int.h → include/ph7int.h View File


ext/dummy/dummy.c → modules/dummy/dummy.c View File


ext/dummy/dummy.h → modules/dummy/dummy.h View File


ext/json/json.c → modules/json/json.c View File


ext/json/json.h → modules/json/json.h View File


ext/xml/lib.c → modules/xml/lib.c View File


ext/xml/lib.h → modules/xml/lib.h View File


ext/xml/xml.c → modules/xml/xml.c View File


ext/xml/xml.h → modules/xml/xml.h View File


interpreter.c → sapi/cli/main.c View File


Loading…
Cancel
Save