Add automatic dependency tracking to the build rules.
Move optional extension modules (e.g. mod_io.c) into mods/ subdir. Fix missing #include in reader.c.
This commit is contained in:
parent
baa2dae345
commit
ca8d68c023
44
Makefile
44
Makefile
|
|
@ -1,35 +1,45 @@
|
|||
CFLAGS = -std=c99 -Wall
|
||||
LDFLAGS = -lrt -lm
|
||||
MODS := io
|
||||
|
||||
CPPFLAGS := -I.
|
||||
CFLAGS := -std=c99 -Wall
|
||||
LDFLAGS := -lrt -lm
|
||||
|
||||
CFLAGS += $(MODS:%=-DHAVE_MOD_%)
|
||||
|
||||
OBJS := rosella.o gc.o builtin.o interp.o reader.o $(MODS:%=mods/mod_%.o)
|
||||
DEPS := $(OBJS:%.o=%.d)
|
||||
GCNO := $(OBJS:%.o=%.gcno)
|
||||
GCDA := $(OBJS:%.o=%.gcda)
|
||||
|
||||
ifeq ($(DEBUG),yes)
|
||||
CFLAGS += -g
|
||||
PROFILE = no
|
||||
dummy := $(shell rm -f rosella *.gcda *.gcno *.o)
|
||||
PROFILE := no
|
||||
dummy := $(shell rm -f rosella $(OBJS) $(GCDA) $(GCNO))
|
||||
else
|
||||
CFLAGS += -O3 -DNDEBUG -march=nocona
|
||||
endif
|
||||
|
||||
all: rosella
|
||||
.PHONY: all clean
|
||||
|
||||
ifeq ($(PROFILE),yes)
|
||||
CFLAGS += -fprofile-generate
|
||||
LDFLAGS += -fprofile-generate
|
||||
endif
|
||||
|
||||
ifneq (,$(wildcard *.gcda))
|
||||
ifneq (,$(wildcard *.gcda mods/*.gcda))
|
||||
CFLAGS += -fprofile-use
|
||||
dummy := $(shell rm -f rosella *.o)
|
||||
dummy := $(shell rm -f rosella $(OBJS))
|
||||
endif
|
||||
|
||||
all: rosella
|
||||
depend: $(DEPS)
|
||||
|
||||
.PHONY: all clean depend
|
||||
|
||||
clean:
|
||||
-rm -f rosella *.o *.gcda *.gcno
|
||||
-rm -f rosella $(OBJS) $(DEPS) $(GCDA) $(GCNO)
|
||||
|
||||
rosella: rosella.o gc.o builtin.o interp.o reader.o io_builtin.o
|
||||
%.d: %.c
|
||||
$(CC) $(CPPFLAGS) -MM $< -MF $@ -MT $(<:%.c=%.o) -MT $@
|
||||
|
||||
rosella.o: rosella.c gc.h builtin.h interp.h
|
||||
gc.o: gc.c gc.h
|
||||
builtin.o: builtin.c builtin.h interp.h gc.h
|
||||
interp.o: interp.c interp.h gc.h builtin.h
|
||||
reader.o: reader.c reader.h gc.h builtin.h
|
||||
io_builtin.o: io_builtin.c io_builtin.h builtin.h interp.h gc.h
|
||||
rosella: $(OBJS)
|
||||
|
||||
-include $(DEPS)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@
|
|||
#include "gc.h"
|
||||
#include "builtin.h"
|
||||
#include "interp.h"
|
||||
#include "io_builtin.h"
|
||||
|
||||
#include "mod_io.h"
|
||||
|
||||
static void bi_posix_open(interp_state_t *state);
|
||||
//static void bi_posix_openat(interp_state_t *state);
|
||||
|
|
@ -24,7 +25,7 @@ static void bi_posix_write(interp_state_t *state);
|
|||
static void bi_posix_lseek(interp_state_t *state);
|
||||
static void bi_posix_close(interp_state_t *state);
|
||||
|
||||
void io_builtin_init(void)
|
||||
void mod_io_init(void)
|
||||
{
|
||||
register_builtin(BI_IO_POSIX_OPEN, make_builtin_fn(bi_posix_open));
|
||||
//register_builtin(BI_IO_POSIX_OPENAT, make_builtin_fn(bi_posix_openat));
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#define BI_IO_POSIX_CLOSE "posix-close"
|
||||
|
||||
void io_builtin_init(void);
|
||||
void mod_io_init(void);
|
||||
|
||||
#endif
|
||||
/* vim:set sw=2 expandtab: */
|
||||
2
reader.c
2
reader.c
|
|
@ -15,6 +15,8 @@
|
|||
#include "gc.h"
|
||||
#include "builtin.h"
|
||||
|
||||
#include "reader.h"
|
||||
|
||||
typedef struct reader_state
|
||||
{
|
||||
FILE *file;
|
||||
|
|
|
|||
10
rosella.c
10
rosella.c
|
|
@ -11,7 +11,10 @@
|
|||
#include "builtin.h"
|
||||
#include "interp.h"
|
||||
#include "reader.h"
|
||||
#include "io_builtin.h"
|
||||
|
||||
#ifdef HAVE_MOD_io
|
||||
# include "mods/mod_io.h"
|
||||
#endif
|
||||
|
||||
static void test_builtins(void);
|
||||
static void test_weak_boxes_and_wills(void);
|
||||
|
|
@ -35,7 +38,10 @@ int main(int argc, char **argv)
|
|||
gc_init(256*1024, 1024*1024);
|
||||
builtin_init();
|
||||
interpreter_init();
|
||||
io_builtin_init();
|
||||
|
||||
#ifdef HAVE_MOD_io
|
||||
mod_io_init();
|
||||
#endif
|
||||
|
||||
if (argc < 2 || (strcmp(argv[1], "-t") == 0) || (strcmp(argv[1], "--test") == 0))
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue