-
Notifications
You must be signed in to change notification settings - Fork 1
Home
No More than a C building system for clang, gcc and msvc.
There are no installation process just setup bash and make environment.
The most simplest way to configure is into your C application directory and run
bash <(curl https://raw.githubusercontent.com/junjiemars/nore/master/bootstrap.sh)
then done.
On Windows, because there are no bash by default, so We need install Git Bash first, and select 'unix compatible tools' when installing. Run bash
in any CMD
or MSYS
, then
bash <(curl https://raw.githubusercontent.com/junjiemars/nore/master/bootstrap.sh)
In this process, the bootstrap.sh
will configuration bash environment and install GNU Make if there hadn't installed yet.
There are an example at https://github.com/junjiemars/nore-hi,
$ git clone --depth=1 https://github.com/junjiemars/nore-hi.git
The nore-hi directory look like this:
.
├── LICENSE
├── Makefile
├── README.md
└── hi
├── Makefile
├── hi.c
└── version
After configuration, it's look like:
.
├── LICENSE
├── Makefile (generated by Nore)
├── README.md
├── configure (generated by Nore)
└── hi
├── Makefile
├── hi.c
└── version
Now, a story of classic workflow begins:
- compose a Makefile, here we use
hi/Makefile
; -
./configure --has-hi --prefix=/tmp
, after configured, the structure of working directory looks like:
.
├── LICENSE
├── Makefile
├── README.md
├── configure
├── hi
│ ├── Makefile
│ ├── hi.c
│ └── version
└── objs (generated by Nore)
├── Makefile (generated by Nore base on your hi/Makefile)
├── autoconf.err
├── bin
├── conf
├── inc
├── lib
├── log
├── nm_auto_config.h
├── nm_auto_header.h
├── pid
└── tmp
make
make install
The objs/Makefile
be generated by Nore base on hi/Makefile
# hi/Makefile
hi_binout := $(bin_path)hi$(bin_ext)
# note: hi target has same name with the directory
hi: $(hi_binout)
hi_test: hi
$(hi_binout)
$(hi_binout): $(src_path)hi.c
$(CC) $(CFLAGS) $(INC) $^ $(bin_out)$@
All elements of hi/Makefile
can be found in objs/makefile
:
# objs/Makefile (clang, MacOS)
CC = cc
CPP = $(CC)
CAS = $(CC)
AS = $(CC)
AR = ar
LINK = $(CC)
CPPFLAGS =
CFLAGS = -std=c99 -g -Wall -Wextra -Wpointer-arith -Wconditional-uninitialized -Wunused-variable -Wunused-parameter -Wno-error=unused-command-line-argument -Werror
ASFLAGS =
LDLIBS =
LDFLAGS =
ARFLAGS =
LFLAGS =
YFLAGS =
LDFLAGS = -Lobjs/lib
INC = -Iobjs -Iobjs/inc
nm_symbol_opt = -g
nm_optimize_opt = -O2
nm_warn_opt = -Wall -Wextra -Wpointer-arith -Wconditional-uninitialized -Wunused-variable -Wunused-parameter -Wno-error=unused-command-line-argument
nm_error_opt = -Werror
nm_debug_opt =
nm_std_opt = -std=c99
nm_cpu_opt =
nm_verbose_opt = -v
nm_pic_opt =
nm_shared_opt = -dynamiclib
nm_stage_pre = -E
nm_stage_chk = -fsyntax-only
nm_stage_asm = -S
nm_stage_c = -c
# path separator
nm_p = :
src_root = ./
# nore options
NM_SYMBOL = YES
NM_OPTIMIZE = NO
NM_WARN = YES
NM_ERROR = YES
NM_DEBUG = YES
NM_VERBOSE = NO
NM_STD = YES
NM_CPU = NO
# platform
NM_SYSTEM = Darwin
NM_RELEASE = 16.7.0
NM_MACHINE = x86_64
CC_NAME = clang
# output option
cpp_out = -o
asm_out = -o
obj_out = -o
lib_out = -o
ar_out = rcs
bin_out = -o
# output extension
cpp_ext = .i
asm_ext = .s
obj_ext = .o
lib_ext = .dylib
ar_ext = .a
bin_ext =
default: build
clean:
$(RM) -r objs/bin/*
$(RM) -r objs/lib/*
$(RM) -r objs/inc/*
$(RM) -r objs/log/*
$(RM) -r objs/pid/*
$(RM) -r objs/tmp/*
$(RM) -r objs/conf/*
.PHONY: hi hi_test
build: hi
test: hi_test
#---------------------------------------
hi_binout := objs/bin/hi$(bin_ext)
hi: $(hi_binout)
hi_test: hi
$(hi_binout)
$(hi_binout): ./hi/hi.c
$(CC) $(CFLAGS) $(INC) $^ $(bin_out)$@
#---------------------------------------
install: build /tmp/bin /tmp/lib /tmp/conf /tmp/inc
$(call cp-if, objs/bin, /tmp/bin/)
$(call cp-if, objs/lib, /tmp/lib/)
$(call cp-if, objs/conf, /tmp/conf/)
$(call cp-if, objs/inc, /tmp/inc/)
/tmp/bin /tmp/lib /tmp/conf /tmp/inc:
$(call mkdir-if, /tmp/bin)
$(call mkdir-if, /tmp/lib)
$(call mkdir-if, /tmp/conf)
$(call mkdir-if, /tmp/inc)
$(call mkdir-if, /tmp/log)
mkdir-if = $(if $(wildcard $1),,mkdir -p $1)
cp-if = $(foreach f,$(wildcard $1/*),$(shell cp -r $(f) $2))