mirror of
https://github.com/janet-lang/janet
synced 2024-11-24 09:17:17 +00:00
Revert to GNU Makefile.
This commit is contained in:
parent
99f9e4836f
commit
ba2c4b265b
38
Makefile
38
Makefile
@ -17,7 +17,6 @@
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
# IN THE SOFTWARE.
|
||||
.POSIX:
|
||||
|
||||
################################
|
||||
##### Set global variables #####
|
||||
@ -28,8 +27,9 @@ PREFIX?=/usr/local
|
||||
INCLUDEDIR=$(PREFIX)/include/janet
|
||||
LIBDIR=$(PREFIX)/lib
|
||||
BINDIR=$(PREFIX)/bin
|
||||
JANET_VERSION?="\"0.0.0-alpha\""
|
||||
JANET_VERSION?="\"commit-$(shell git log --pretty=format:'%h' -n 1)\""
|
||||
|
||||
#CFLAGS=-std=c99 -Wall -Wextra -Isrc/include -fpic -g -DJANET_VERSION=$(JANET_VERSION)
|
||||
CFLAGS=-std=c99 -Wall -Wextra -Isrc/include -fpic -O2 -fvisibility=hidden \
|
||||
-DJANET_VERSION=$(JANET_VERSION)
|
||||
CLIBS=-lm -ldl
|
||||
@ -38,21 +38,27 @@ JANET_LIBRARY=libjanet.so
|
||||
JANET_PATH?=/usr/local/lib/janet
|
||||
DEBUGGER=gdb
|
||||
|
||||
# Some system specifics (for macOS)
|
||||
LDCONFIG!=[ $$(uname -s) != Darwin ] && echo "ldconfig"
|
||||
CLIBS:=$(CLIBS) $(shell [ $$(uname -s) != Darwin ] && echo "-lrt -rdynamic")
|
||||
UNAME:=$(shell uname -s)
|
||||
LDCONFIG:=ldconfig
|
||||
ifeq ($(UNAME), Darwin)
|
||||
# Add other macos/clang flags
|
||||
LDCONFIG:=
|
||||
else
|
||||
CFLAGS:=$(CFLAGS) -rdynamic
|
||||
CLIBS:=$(CLIBS) -lrt
|
||||
endif
|
||||
|
||||
# Source headers
|
||||
JANET_GENERATED_HEADERS= \
|
||||
src/include/generated/core.h \
|
||||
src/include/generated/init.h
|
||||
JANET_HEADERS!=find src/include/janet -type f -name *.h
|
||||
JANET_CORE_HEADERS!=find src/core -type f -name *.h
|
||||
JANET_HEADERS=$(sort $(wildcard src/include/janet/*.h))
|
||||
JANET_LOCAL_HEADERS=$(sort $(wildcard src/*/*.h))
|
||||
|
||||
# Source files
|
||||
JANET_CORE_SOURCES!=find src/core/ -type f -name *.c
|
||||
JANET_MAINCLIENT_SOURCES!=find src/mainclient -type f -name *.c
|
||||
JANET_WEBCLIENT_SOURCES!=find src/webclient -type f -name *.c
|
||||
JANET_CORE_SOURCES=$(sort $(wildcard src/core/*.c))
|
||||
JANET_MAINCLIENT_SOURCES=$(sort $(wildcard src/mainclient/*.c))
|
||||
JANET_WEBCLIENT_SOURCES=$(sort $(wildcard src/webclient/*.c))
|
||||
|
||||
all: $(JANET_TARGET) $(JANET_LIBRARY)
|
||||
|
||||
@ -87,8 +93,8 @@ src/mainclient/main.o: src/include/generated/init.h
|
||||
JANET_ALL_SOURCES=$(JANET_CORE_SOURCES) \
|
||||
$(JANET_MAINCLIENT_SOURCES)
|
||||
|
||||
JANET_CORE_OBJECTS=${JANET_CORE_SOURCES:.c=.o}
|
||||
JANET_ALL_OBJECTS=${JANET_ALL_SOURCES:.c=.o}
|
||||
JANET_CORE_OBJECTS=$(patsubst %.c,%.o,$(JANET_CORE_SOURCES))
|
||||
JANET_ALL_OBJECTS=$(patsubst %.c,%.o,$(JANET_ALL_SOURCES))
|
||||
|
||||
%.o: %.c $(JANET_HEADERS) $(JANET_LOCAL_HEADERS)
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
@ -111,7 +117,7 @@ EMCCFLAGS=-std=c99 -Wall -Wextra -Isrc/include -O2 \
|
||||
-DJANET_VERSION=$(JANET_VERSION)
|
||||
JANET_EMTARGET=janet.js
|
||||
JANET_WEB_SOURCES=$(JANET_CORE_SOURCES) $(JANET_WEBCLIENT_SOURCES)
|
||||
JANET_EMOBJECTS=${JANET_WEB_SOURCES:.c=.bc}
|
||||
JANET_EMOBJECTS=$(patsubst %.c,%.bc,$(JANET_WEB_SOURCES))
|
||||
|
||||
# Only a few files depend on generated headers
|
||||
src/core/corelib.bc: src/include/generated/core.h
|
||||
@ -127,9 +133,9 @@ $(JANET_EMTARGET): $(JANET_EMOBJECTS)
|
||||
##### Testing #####
|
||||
###################
|
||||
|
||||
TEST_SOURCES!=find ctest -type f -name *.c
|
||||
TEST_OBJECTS=${TEST_SOURCES:.c=.o}
|
||||
TEST_PROGRAMS=${TEST_SOURCES:.c=.out}
|
||||
TEST_SOURCES=$(wildcard ctest/*.c)
|
||||
TEST_OBJECTS=$(patsubst %.c,%.o,$(TEST_SOURCES))
|
||||
TEST_PROGRAMS=$(patsubst %.c,%.out,$(TEST_SOURCES))
|
||||
|
||||
ctest/%.o: ctest/%.c $(JANET_HEADERS)
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
|
Loading…
Reference in New Issue
Block a user