求教,我的makefile文件哪里出错了

fycfyc123123 2013-12-02 06:00:27
一个IPsec加密程序,代码是从intel官网下载的,里面有个小的测试程序,在应用层跑通了,现在想打包成.ko文件加载到内核中,但是对makefile进行改写后,出现了好多问题。这是makefile的代码
INCLUDE_DIRS := ../include ..
INCLUDES := $(foreach i,$(INCLUDE_DIRS),-I $i)

CC := gcc
CXXFLAGS := -g -D LINUX $(INCLUDES)
LDFLAGS += -g

lib_objs := \
aes128_cbc_dec_by4_sse.o \
aes128_cbc_dec_by8_avx.o \
aes128_cntr_by4_sse.o \
aes128_cntr_by8_avx.o \
aes128_ecbenc_x3.o \
aes192_cbc_dec_by4_sse.o \
aes192_cbc_dec_by8_avx.o \
aes192_cntr_by4_sse.o \
aes192_cntr_by8_avx.o \
aes256_cbc_dec_by4_sse.o \
aes256_cbc_dec_by8_avx.o \
aes256_cntr_by4_sse.o \
aes256_cntr_by8_avx.o \
aes_cbc_enc_128_x4.o \
aes_cbc_enc_128_x8.o \
aes_cbc_enc_192_x4.o \
aes_cbc_enc_192_x8.o \
aes_cbc_enc_256_x4.o \
aes_cbc_enc_256_x8.o \
aes_keyexp_128.o \
aes_keyexp_192.o \
aes_keyexp_256.o \
aes_xcbc_mac_128_x4.o \
aes_xcbc_mac_128_x8.o \
mb_mgr_aes192_flush_avx.o \
mb_mgr_aes192_flush_sse.o \
mb_mgr_aes192_submit_avx.o \
mb_mgr_aes192_submit_sse.o \
mb_mgr_aes256_flush_avx.o \
mb_mgr_aes256_flush_sse.o \
mb_mgr_aes256_submit_avx.o \
mb_mgr_aes256_submit_sse.o \
mb_mgr_aes_flush_avx.o \
mb_mgr_aes_flush_sse.o \
mb_mgr_aes_submit_avx.o \
mb_mgr_aes_submit_sse.o \
mb_mgr_aes_xcbc_flush_avx.o \
mb_mgr_aes_xcbc_flush_sse.o \
mb_mgr_aes_xcbc_submit_avx.o \
mb_mgr_aes_xcbc_submit_sse.o \
mb_mgr_hmac_flush_avx.o \
mb_mgr_hmac_flush_avx2.o \
mb_mgr_hmac_flush_sse.o \
mb_mgr_hmac_md5_flush_avx.o \
mb_mgr_hmac_md5_flush_avx2.o \
mb_mgr_hmac_md5_flush_sse.o \
mb_mgr_hmac_md5_submit_avx.o \
mb_mgr_hmac_md5_submit_avx2.o \
mb_mgr_hmac_md5_submit_sse.o \
mb_mgr_hmac_sha_224_flush_avx.o \
mb_mgr_hmac_sha_224_flush_avx2.o \
mb_mgr_hmac_sha_224_flush_sse.o \
mb_mgr_hmac_sha_224_submit_avx.o \
mb_mgr_hmac_sha_224_submit_avx2.o \
mb_mgr_hmac_sha_224_submit_sse.o \
mb_mgr_hmac_sha_256_flush_avx.o \
mb_mgr_hmac_sha_256_flush_avx2.o \
mb_mgr_hmac_sha_256_flush_sse.o \
mb_mgr_hmac_sha_256_submit_avx.o \
mb_mgr_hmac_sha_256_submit_avx2.o \
mb_mgr_hmac_sha_256_submit_sse.o \
mb_mgr_hmac_sha_384_flush_avx.o \
mb_mgr_hmac_sha_384_flush_avx2.o \
mb_mgr_hmac_sha_384_flush_sse.o \
mb_mgr_hmac_sha_384_submit_avx.o \
mb_mgr_hmac_sha_384_submit_avx2.o \
mb_mgr_hmac_sha_384_submit_sse.o \
mb_mgr_hmac_sha_512_flush_avx.o \
mb_mgr_hmac_sha_512_flush_avx2.o \
mb_mgr_hmac_sha_512_flush_sse.o \
mb_mgr_hmac_sha_512_submit_avx.o \
mb_mgr_hmac_sha_512_submit_avx2.o \
mb_mgr_hmac_sha_512_submit_sse.o \
mb_mgr_hmac_submit_avx.o \
mb_mgr_hmac_submit_avx2.o \
mb_mgr_hmac_submit_sse.o \
md5_x4x2_avx.o \
md5_x4x2_sse.o \
md5_x8x2_avx2.o \
save_xmms.o \
sha1_mult_avx.o \
sha1_mult_sse.o \
sha1_one_block_avx.o \
sha1_one_block_sse.o \
sha1_x8_avx2.o \
sha224_one_block_avx.o \
sha224_one_block_sse.o \
sha256_oct_avx2.o \
sha256_one_block_avx.o \
sha256_one_block_sse.o \
sha384_one_block_avx.o \
sha384_one_block_sse.o \
sha512_one_block_avx.o \
sha512_one_block_sse.o \
sha512_x2_avx.o \
sha512_x2_sse.o \
sha512_x4_avx2.o \
sha_256_mult_avx.o \
sha_256_mult_sse.o \
gcm_defines.o\
mb_mgr_datastruct.o\
job_aes_hmac.o\
constants.o\
aes_xcbc_expand_key.o \
mb_mgr_avx.o \
mb_mgr_avx2.o \
mb_mgr_sse.o \
md5_one_block.o\
gcm_sse.o \
gcm_avx_gen2.o \
gcm_avx_gen4.o

OBJ := $(foreach i,$(lib_objs),../obj/$(i))

KERNELBUILD := /lib/modules/$(shell uname -r)/build
default:
make -C $(KERNELBUILD) M=$(shell pwd) modules

main.o: main.c do_test.h $(OBJ)
$(CC) $(CXXFLAGS) -c $< -o $@

obj-m += gcm.o
gcm-objs:= main.o $(OBJ)


install:
insmod gcm.ko
clean:
rm -f *.o *.cmd *.ko *.mod.c


make出现错误:
make -C /lib/modules/2.6.38-8-generic/build M=/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp modules
make[1]: 正在进入目录 `/usr/src/linux-headers-2.6.38-8-generic'
CC [M] /home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/main.o
In file included from /home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/main.c:41:0:
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:147:6: warning: "TEST" is not defined
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:147:14: warning: "TEST_SSE" is not defined
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h: In function ‘TEST_GCM’:
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:281:5: error: ‘UINT64’ undeclared (first use in this function)
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:281:5: note: each undeclared identifier is reported only once for each function it appears in
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:281:12: error: expected ‘;’ before ‘keys128’
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:282:5: error: ‘UINT8’ undeclared (first use in this function)
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:282:11: error: expected ‘;’ before ‘plaintext’
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:283:11: error: expected ‘;’ before ‘ciphertext’
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:287:5: error: implicit declaration of function ‘DECLARE_ALIGNED’
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:287:27: error: expected ‘)’ before ‘iv’
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:287:41: error: expected expression before ‘{’ token
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:288:11: error: expected ‘;’ before ‘aad’
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:289:27: error: expected ‘)’ before ‘hashSubKey’
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:289:49: error: expected expression before ‘{’ token
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:291:11: error: expected ‘;’ before ‘auth_tag’
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:293:5: error: ‘gcm_data’ undeclared (first use in this function)
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:293:14: error: expected ‘;’ before ‘gdata’
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:294:28: error: expected ‘)’ before ‘exp_keys’
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:295:11: error: expected ‘;’ before ‘text’
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:296:11: error: expected ‘;’ before ‘auth_test’
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:297:5: warning: ISO C90 forbids mixed declarations and code
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:300:5: error: implicit declaration of function ‘aes_keyexp_128_enc’
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:300:24: error: ‘keys128’ undeclared (first use in this function)
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:300:33: error: ‘gdata’ undeclared (first use in this function)
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:301:5: error: implicit declaration of function ‘aesni_gcm_precomp’
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:301:31: error: ‘hashSubKey’ undeclared (first use in this function)
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:303:5: error: implicit declaration of function ‘aesni_gcm_enc’
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:303:33: error: ‘plaintext’ undeclared (first use in this function)
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:303:63: error: ‘iv’ undeclared (first use in this function)
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:304:19: error: ‘aad’ undeclared (first use in this function)
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:304:37: error: ‘auth_test’ undeclared (first use in this function)
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:307:24: error: ‘ciphertext’ undeclared (first use in this function)
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:312:24: error: ‘auth_tag’ undeclared (first use in this function)
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:319:5: error: implicit declaration of function ‘aesni_gcm_dec’
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h: At top level:
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/do_test.h:341:16: error: expected ‘)’ before ‘*’ token
/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/main.c:43:20: fatal error: mb_mgr.h: 没有那个文件或目录
compilation terminated.
make[2]: *** [/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp/main.o] 错误 1
make[1]: *** [_module_/home/zjz/桌面/IPsec_006_code_EDC_v2-kernel/code/LibTestApp] 错误 2
make[1]:正在离开目录 `/usr/src/linux-headers-2.6.38-8-generic'
make: *** [default] 错误 2


情况就是这样,代码在应用层是可以的,我只是修改了几个头文件还有printf变成了printk之类的,然后修改了下makefile,就出现了这么些错误,真心求教各位
...全文
299 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
falloutmx 2013-12-03
  • 打赏
  • 举报
回复
都是未定义,用make -n看下实际执行的命令,有没有包含那些头文件所在的目录
fycfyc123123 2013-12-03
  • 打赏
  • 举报
回复
引用 2 楼 pottichu 的回复:
用户态的程序,不能在内核态跑。。。。
这个我知道啊,所以修改了源程序中的几个头文件还有例如printf之类的,然后修改了一下原来的Makefile,结果就出错了
pottichu 2013-12-02
  • 打赏
  • 举报
回复
用户态的程序,不能在内核态跑。。。。
fycfyc123123 2013-12-02
  • 打赏
  • 举报
回复
这是没有修改的应用层的makefile INCLUDE_DIRS := ../include .. INCLUDES := $(foreach i,$(INCLUDE_DIRS),-I $i) CC := gcc CXXFLAGS := -g -D LINUX $(INCLUDES) LDFLAGS += -g lib_objs := \ aes128_cbc_dec_by4_sse.o \ aes128_cbc_dec_by8_avx.o \ aes128_cntr_by4_sse.o \ aes128_cntr_by8_avx.o \ aes128_ecbenc_x3.o \ aes192_cbc_dec_by4_sse.o \ aes192_cbc_dec_by8_avx.o \ aes192_cntr_by4_sse.o \ aes192_cntr_by8_avx.o \ aes256_cbc_dec_by4_sse.o \ aes256_cbc_dec_by8_avx.o \ aes256_cntr_by4_sse.o \ aes256_cntr_by8_avx.o \ aes_cbc_enc_128_x4.o \ aes_cbc_enc_128_x8.o \ aes_cbc_enc_192_x4.o \ aes_cbc_enc_192_x8.o \ aes_cbc_enc_256_x4.o \ aes_cbc_enc_256_x8.o \ aes_keyexp_128.o \ aes_keyexp_192.o \ aes_keyexp_256.o \ aes_xcbc_mac_128_x4.o \ aes_xcbc_mac_128_x8.o \ mb_mgr_aes192_flush_avx.o \ mb_mgr_aes192_flush_sse.o \ mb_mgr_aes192_submit_avx.o \ mb_mgr_aes192_submit_sse.o \ mb_mgr_aes256_flush_avx.o \ mb_mgr_aes256_flush_sse.o \ mb_mgr_aes256_submit_avx.o \ mb_mgr_aes256_submit_sse.o \ mb_mgr_aes_flush_avx.o \ mb_mgr_aes_flush_sse.o \ mb_mgr_aes_submit_avx.o \ mb_mgr_aes_submit_sse.o \ mb_mgr_aes_xcbc_flush_avx.o \ mb_mgr_aes_xcbc_flush_sse.o \ mb_mgr_aes_xcbc_submit_avx.o \ mb_mgr_aes_xcbc_submit_sse.o \ mb_mgr_hmac_flush_avx.o \ mb_mgr_hmac_flush_avx2.o \ mb_mgr_hmac_flush_sse.o \ mb_mgr_hmac_md5_flush_avx.o \ mb_mgr_hmac_md5_flush_avx2.o \ mb_mgr_hmac_md5_flush_sse.o \ mb_mgr_hmac_md5_submit_avx.o \ mb_mgr_hmac_md5_submit_avx2.o \ mb_mgr_hmac_md5_submit_sse.o \ mb_mgr_hmac_sha_224_flush_avx.o \ mb_mgr_hmac_sha_224_flush_avx2.o \ mb_mgr_hmac_sha_224_flush_sse.o \ mb_mgr_hmac_sha_224_submit_avx.o \ mb_mgr_hmac_sha_224_submit_avx2.o \ mb_mgr_hmac_sha_224_submit_sse.o \ mb_mgr_hmac_sha_256_flush_avx.o \ mb_mgr_hmac_sha_256_flush_avx2.o \ mb_mgr_hmac_sha_256_flush_sse.o \ mb_mgr_hmac_sha_256_submit_avx.o \ mb_mgr_hmac_sha_256_submit_avx2.o \ mb_mgr_hmac_sha_256_submit_sse.o \ mb_mgr_hmac_sha_384_flush_avx.o \ mb_mgr_hmac_sha_384_flush_avx2.o \ mb_mgr_hmac_sha_384_flush_sse.o \ mb_mgr_hmac_sha_384_submit_avx.o \ mb_mgr_hmac_sha_384_submit_avx2.o \ mb_mgr_hmac_sha_384_submit_sse.o \ mb_mgr_hmac_sha_512_flush_avx.o \ mb_mgr_hmac_sha_512_flush_avx2.o \ mb_mgr_hmac_sha_512_flush_sse.o \ mb_mgr_hmac_sha_512_submit_avx.o \ mb_mgr_hmac_sha_512_submit_avx2.o \ mb_mgr_hmac_sha_512_submit_sse.o \ mb_mgr_hmac_submit_avx.o \ mb_mgr_hmac_submit_avx2.o \ mb_mgr_hmac_submit_sse.o \ md5_x4x2_avx.o \ md5_x4x2_sse.o \ md5_x8x2_avx2.o \ save_xmms.o \ sha1_mult_avx.o \ sha1_mult_sse.o \ sha1_one_block_avx.o \ sha1_one_block_sse.o \ sha1_x8_avx2.o \ sha224_one_block_avx.o \ sha224_one_block_sse.o \ sha256_oct_avx2.o \ sha256_one_block_avx.o \ sha256_one_block_sse.o \ sha384_one_block_avx.o \ sha384_one_block_sse.o \ sha512_one_block_avx.o \ sha512_one_block_sse.o \ sha512_x2_avx.o \ sha512_x2_sse.o \ sha512_x4_avx2.o \ sha_256_mult_avx.o \ sha_256_mult_sse.o \ \ aes_xcbc_expand_key.o \ mb_mgr_avx.o \ mb_mgr_avx2.o \ mb_mgr_sse.o \ md5_one_block.o \ gcm_sse.o \ gcm_avx_gen2.o \ gcm_avx_gen4.o OBJ := $(foreach i,$(lib_objs),../obj/$(i)) gcm: main.o $(OBJ) $(CC) -o gcm main.o $(OBJ) main.o: main.c do_test.h $(OBJ) $(CC) $(CXXFLAGS) -c $< -o $@ clean: rm -f *.o *.cmd *.ko *.mod.c

4,441

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧