summary refs log tree commit diff
path: root/src/CMakeLists.txt
blob: dc3770ecb69ac3b3435b5a80572584d53c2dde8d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
add_compile_options(-Wall)
add_compile_definitions(BSD=1 SHELL)

add_compile_options(-include ${CMAKE_BINARY_DIR}/config.h)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})

set(
	CFILES
	alias.c arith_yacc.c arith_yylex.c cd.c error.c eval.c exec.c expand.c
	histedit.c input.c jobs.c mail.c main.c memalloc.c miscbltin.c
	mystring.c options.c parser.c redir.c show.c trap.c output.c
	bltin/printf.c system.c bltin/test.c bltin/times.c var.c
)

add_executable(
	dash
	${CFILES}
	alias.h arith_yacc.h bltin/bltin.h cd.h error.h eval.h exec.h
	expand.h
	init.h input.h jobs.h machdep.h mail.h main.h memalloc.h miscbltin.h
	myhistedit.h mystring.h options.h output.h parser.h redir.h shell.h
	show.h system.h trap.h var.h
	builtins.c builtins.h init.c nodes.c nodes.h signames.c syntax.c syntax.h
)

install(TARGETS dash)
install(FILES dash.1 TYPE MAN RENAME man1/dash.1)

add_executable(mkinit EXCLUDE_FROM_ALL mkinit.c)
add_executable(mksyntax EXCLUDE_FROM_ALL mksyntax.c token.h)
add_executable(mknodes EXCLUDE_FROM_ALL mknodes.c)
add_executable(mksignames EXCLUDE_FROM_ALL mksignames.c)

add_custom_command(
	OUTPUT token.h token_vars.h
	COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/mktokens
	DEPENDS mktokens
	VERBATIM
)
add_custom_command(
	OUTPUT builtins.def
	COMMAND ${CMAKE_C_COMPILER}
		"-D$<JOIN:$<TARGET_PROPERTY:dash,COMPILE_DEFINITIONS>,;-D>"
		$<TARGET_PROPERTY:dash,COMPILE_OPTIONS>
		-E -x c ${CMAKE_CURRENT_SOURCE_DIR}/builtins.def.in
		-o ${CMAKE_CURRENT_BINARY_DIR}/builtins.def
	DEPENDS builtins.def.in ${CMAKE_BINARY_DIR}/config.h
	VERBATIM
	COMMAND_EXPAND_LISTS
)
add_custom_command(
	OUTPUT builtins.c builtins.h
	COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/mkbuiltins
		${CMAKE_CURRENT_BINARY_DIR}/builtins.def
	DEPENDS mkbuiltins builtins.def
	VERBATIM
)
list(TRANSFORM CFILES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/")
add_custom_command(
	OUTPUT init.c
	COMMAND mkinit ${CFILES}
	DEPENDS ${CFILES}
	VERBATIM
	COMMAND_EXPAND_LISTS
)
add_custom_command(
	OUTPUT nodes.c nodes.h
	COMMAND mknodes
		${CMAKE_CURRENT_SOURCE_DIR}/nodetypes
		${CMAKE_CURRENT_SOURCE_DIR}/nodes.c.pat
	DEPENDS nodetypes nodes.c.pat
	VERBATIM
)
add_custom_command(
	OUTPUT syntax.c syntax.h
	COMMAND mksyntax
	VERBATIM
)
add_custom_command(
	OUTPUT signames.c
	COMMAND mksignames
	VERBATIM
)