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
|
MODS := io
|
||||||
LDFLAGS = -lrt -lm
|
|
||||||
|
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)
|
ifeq ($(DEBUG),yes)
|
||||||
CFLAGS += -g
|
CFLAGS += -g
|
||||||
PROFILE = no
|
PROFILE := no
|
||||||
dummy := $(shell rm -f rosella *.gcda *.gcno *.o)
|
dummy := $(shell rm -f rosella $(OBJS) $(GCDA) $(GCNO))
|
||||||
else
|
else
|
||||||
CFLAGS += -O3 -DNDEBUG -march=nocona
|
CFLAGS += -O3 -DNDEBUG -march=nocona
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all: rosella
|
|
||||||
.PHONY: all clean
|
|
||||||
|
|
||||||
ifeq ($(PROFILE),yes)
|
ifeq ($(PROFILE),yes)
|
||||||
CFLAGS += -fprofile-generate
|
CFLAGS += -fprofile-generate
|
||||||
LDFLAGS += -fprofile-generate
|
LDFLAGS += -fprofile-generate
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq (,$(wildcard *.gcda))
|
ifneq (,$(wildcard *.gcda mods/*.gcda))
|
||||||
CFLAGS += -fprofile-use
|
CFLAGS += -fprofile-use
|
||||||
dummy := $(shell rm -f rosella *.o)
|
dummy := $(shell rm -f rosella $(OBJS))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
all: rosella
|
||||||
|
depend: $(DEPS)
|
||||||
|
|
||||||
|
.PHONY: all clean depend
|
||||||
|
|
||||||
clean:
|
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
|
rosella: $(OBJS)
|
||||||
gc.o: gc.c gc.h
|
|
||||||
builtin.o: builtin.c builtin.h interp.h gc.h
|
-include $(DEPS)
|
||||||
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
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,8 @@
|
||||||
#include "gc.h"
|
#include "gc.h"
|
||||||
#include "builtin.h"
|
#include "builtin.h"
|
||||||
#include "interp.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_open(interp_state_t *state);
|
||||||
//static void bi_posix_openat(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_lseek(interp_state_t *state);
|
||||||
static void bi_posix_close(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_OPEN, make_builtin_fn(bi_posix_open));
|
||||||
//register_builtin(BI_IO_POSIX_OPENAT, make_builtin_fn(bi_posix_openat));
|
//register_builtin(BI_IO_POSIX_OPENAT, make_builtin_fn(bi_posix_openat));
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#define BI_IO_POSIX_CLOSE "posix-close"
|
#define BI_IO_POSIX_CLOSE "posix-close"
|
||||||
|
|
||||||
void io_builtin_init(void);
|
void mod_io_init(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/* vim:set sw=2 expandtab: */
|
/* vim:set sw=2 expandtab: */
|
||||||
2
reader.c
2
reader.c
|
|
@ -15,6 +15,8 @@
|
||||||
#include "gc.h"
|
#include "gc.h"
|
||||||
#include "builtin.h"
|
#include "builtin.h"
|
||||||
|
|
||||||
|
#include "reader.h"
|
||||||
|
|
||||||
typedef struct reader_state
|
typedef struct reader_state
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
|
|
||||||
10
rosella.c
10
rosella.c
|
|
@ -11,7 +11,10 @@
|
||||||
#include "builtin.h"
|
#include "builtin.h"
|
||||||
#include "interp.h"
|
#include "interp.h"
|
||||||
#include "reader.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_builtins(void);
|
||||||
static void test_weak_boxes_and_wills(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);
|
gc_init(256*1024, 1024*1024);
|
||||||
builtin_init();
|
builtin_init();
|
||||||
interpreter_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))
|
if (argc < 2 || (strcmp(argv[1], "-t") == 0) || (strcmp(argv[1], "--test") == 0))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue