您尚未登录。

#1 2012-06-18 17:24:53

ljj_jjl2008
会员
注册时间: 2012-06-02
帖子: 33

来寻求帮助了,关于makefile文件的。特别是Arch用户,和“贱兔”用户,请进。

在研究怎么实现make/make install。
学了很久,实在是学不会autocfg和cmake的用法,一生气,手动写了一个固定的makefile(这个没有cmake,也没有./congigure),和一个install脚本。本机测试已经通过。make命令:
make
sudo make -e INSTDIR=<安装目录>
现在把整理以后的目录结构,makefile、install脚本列示出来,请懂这个的帮忙看看,特别是Arch用户。
另外,请Arch用户看看,这个Makefile能不能用于PKGBUILD,如果能,PKGBUILD怎么写?如果不能,怎么修改才能用于Arch?
另另外,请“贱兔”用户也看看,这个Makefile能不能用于“贱兔”

.
├── bin (存放编译结果)
├── etc (配置文件目录)
├── share(共享文件)
│   ├── iconcache
│   ├── icons
│   ├── pics
│   └── weather-icon
├── shell(脚本)
├── src(源码)
└── xsessions(xsessions文件)

工程跟目录下面,有3个文件:install、 Makefile、 readme.txt。

TARGET = icon-de
INC0 = -lX11
INC1 = -lImlib2 -lXmu
INC2 = `pkg-config --cflags --libs glib-2.0`
CXX = g++
icon-wharf:./bin/icon-wharf
	$(CXX) -o ./bin/icon-wharf ./src/icon-wharf.c  $(INC0)
	$(CXX) -o ./bin/iconrun1 ./src/iconrun1.c  $(INC0) $(INC1) $(INC2)
	$(CXX) -o ./bin/iconrun2 ./src/iconrun2.c  $(INC0) $(INC1) $(INC2)
	$(CXX) -o ./bin/iconrun3 ./src/iconrun3.c  $(INC0) $(INC1) $(INC2)
	$(CXX) -o ./bin/icon-bord ./src/icon-bord.c  $(INC0) $(INC1) $(INC2)
	$(CXX) -o ./bin/iconrun4 ./src/iconrun4.c  $(INC0) $(INC1) $(INC2)
	$(CXX) -o ./bin/icon-clock ./src/icon-clock.c  $(INC0) $(INC1) $(INC2)
	$(CXX) -o ./bin/icon-dock ./src/icon-dock.c  $(INC0) $(INC1) $(INC2)
	$(CXX) -o ./bin/icon-panel ./src/icon-panel.c  $(INC0) $(INC2) -lXft
	$(CXX) -o ./bin/iconweather ./src/iconweather.c $(INC0) $(INC1) $(INC2)
	$(CXX) -o ./bin/icon-desk ./src/icon-desk.c -lXinerama -lXft  -lX11 -lImlib2 -lXmu  `pkg-config --cflags --libs glib-2.0` `giblib-config --cflags --libs` -lcurl -lpng -lXcomposite -lXdamage -lXfixes -lXrender  -lm 
	$(CXX) -o ./bin/icon-trans ./src/icon-trans.c `pkg-config --cflags --libs xcomposite xfixes xdamage xrender glib-2.0`
	$(CXX) -o ./bin/icon-wmvm ./src/icon-wmvm.c $(INC0) $(INC2)
	$(CXX) -o ./bin/icon-wmcl ./src/icon-wmcl.c  $(INC0) $(INC1) $(INC2)

clean:./bin/icon-wharf
	-rm ./bin/*

INSTDIR = /home/lijianjun/icon_de_make/make

.PHONY: install
install:
	./install  $(shell pwd) $(INSTDIR)
	
.PHONY: uninstall
uninstall:
	-rm -rf $(INSTDIR)/etc/icon-de/*
	-rm -rf $(INSTDIR)/etc/icon-de
	-rm -rf $(INSTDIR)/usr/share/icon-DE/*
	-rm -rf $(INSTDIR)/usr/bin/bin/icon-bord
	-rm -rf $(INSTDIR)/usr/bin/bin/icon-clock
	-rm -rf $(INSTDIR)/usr/bin/bin/icon-desk
	-rm -rf $(INSTDIR)/usr/bin/bin/icon-dock
	-rm -rf $(INSTDIR)/usr/bin/bin/icon-panel
	-rm -rf $(INSTDIR)/usr/bin/bin/icon-trans
	-rm -rf $(INSTDIR)/usr/bin/bin/icon-wharf
	-rm -rf $(INSTDIR)/usr/bin/bin/icon-wmcl
	-rm -rf $(INSTDIR)/usr/bin/bin/icon-wmvm
	-rm -rf $(INSTDIR)/usr/bin/bin/iconrun1
	-rm -rf $(INSTDIR)/usr/bin/bin/iconrun2
	-rm -rf $(INSTDIR)/usr/bin/bin/iconrun3
	-rm -rf $(INSTDIR)/usr/bin/bin/iconrun4
	-rm -rf $(INSTDIR)/usr/bin/bin/iconweather
	-rm -rf $(INSTDIR)/usr/bin/shell/icon_de
	-rm -rf $(INSTDIR)/usr/bin/shell/icon_de_init
	-rm -rf $(INSTDIR)/usr/bin/shell/select_wm
	-rm -f $(INSTDIR)/usr/share/xsessions/icon-DE.desktop
	-rm -f /usr/share/kde4/apps/kdm/sessions/icon-DE.desktop
	-rm -f /usr/share/apps/kdm/sessions/icon-DE.desktop
	-rm -rf ~/.icon-DE/*
	-rm -rf ~/.icon-DE
	-rm -f ~/icon_de_install
	-rm -f ~/icon_de_init_log.txt
#!/bin/bash
if [ ! -d "$2/usr/" ] ; then
    mkdir $2/usr
fi
if [ ! -d "$2/usr/bin/" ] ; then
    mkdir $2/usr/bin
fi
if [ ! -d "$2/usr/" ] ; then
    mkdir $2/usr
fi
if [ ! -d "$2/usr/share/" ] ; then
    mkdir $2/usr/share
fi
if [ ! -d "$2/usr/share/xsessions/" ] ; then
    mkdir $2/usr/share/xsessions
fi
if [ ! -d "$2/usr/share/icon-DE/" ] ; then
    mkdir $2/usr/share/icon-DE
fi
if [ ! -d "$2/usr/share/icon-DE/fonts/" ] ; then
    mkdir $2/usr/share/icon-DE/fonts
fi
if [ ! -d "$2/usr/share/icon-DE/src/" ] ; then
    mkdir $2/usr/share/icon-DE/src
fi
if [ ! -d "$2/etc/" ] ; then
    mkdir $2/etc
fi
if [ ! -d "$2/etc/icon-de/" ] ; then
    mkdir $2/etc/icon-de
fi
cp $1/bin/* $2/usr/bin/ -a
cp $1/shell/* $2/usr/bin/ -a
cp $1/xsessions/icon-DE.desktop $2/usr/share/xsessions
chown root $2/usr/share/xsessions/icon-DE.desktop
cp $1/etc/* $2/etc/icon-de/
cp -a $1/share/* $2/usr/share/icon-DE/ -rf
cp -a $1/src/* $2/usr/share/icon-DE/src/
if [ -f /usr/share/fonts/truetype/wqy/wqy-zenhei.ttc ] ; then
    cp /usr/share/fonts/truetype/wqy/wqy-zenhei.ttc $2/usr/share/icon-DE/fonts/Vera.ttf
fi
if [ -f /usr/share/fonts/wenquanyi/wqy-zenhei/wqy-zenhei.ttc ] ; then
    cp /usr/share/fonts/wenquanyi/wqy-zenhei/wqy-zenhei.ttc $2/usr/share/icon-DE/fonts/Vera.ttf
fi
if [ ! -f ~/.icon-DE/wharf.rc ] ; then
    mkdir ~/.icon-DE
    mkdir ~/.icon-DE/fonts
    cp $2/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc ~/.icon-DE/fonts/Vera.ttf
    cp -a $2/usr/share/icon-DE/* ~/.icon-DE/
    cp -a $2/etc/icon-de/* ~/.icon-DE/
    chown `who am i| awk '{print $2}'`:`id \`who am i| awk '{print $2}'\` -grn` ~/.icon-DE
    chown -R `who am i| awk '{print $2}'`:`id \`who am i| awk '{print $2}'\` -grn` ~/.icon-DE/*
fi
if [ -f ~/.icon-DE/weather-icon/晴.png ] ; then
    rm -rf ~/.icon-DE/weather-icon/*.png
    cp -a $2/usr/share/icon-DE//weather-icon/* ~/.icon-DE/weather-icon/
    chown `who am i| awk '{print $2}'`:`id \`who am i| awk '{print $2}'\` -grn` ~/.icon-DE/weather-icon
    chown -R `who am i| awk '{print $2}'`:`id \`who am i| awk '{print $2}'\` -grn` ~/.icon-DE/weather-icon/*
fi
if [ -e $2/usr/bin/kdm ] ; then
    if [ -d /usr/share/kde4/apps/kdm/sessions/ ] ; then
        cp $2/usr/share/xsessions/icon-DE.desktop /usr/share/kde4/apps/kdm/sessions/
    fi
    if [ -d /usr/share/apps/kdm/sessions/ ] ; then
        cp $2/usr/share/xsessions/icon-DE.desktop /usr/share/apps/kdm/sessions/
    fi
fi
if [ ! -f ~/.icon-DE/icon-de.rc ] ; then
    cp -a $2/etc/icon-de/icon-de.rc ~/.icon-DE/icon-de.rc
    chown `who am i| awk '{print $2}'`:`id \`who am i| awk '{print $2}'\` -grn` ~/.icon-DE
    chown -R `who am i| awk '{print $2}'`:`id \`who am i| awk '{print $2}'\` -grn` ~/.icon-DE/*
fi
echo "Please Run Command: icon_de_init"

关键是makefile文件里面这一句:

.PHONY: install
install:
	./install  $(shell pwd) $(INSTDIR)

这么写行么?这么写如果提交到Arch的AUR、或者其他带自动编译功能的站点,编译能通过么?
这是所有的软件源码:http://forum.ubuntu.org.cn/download/file.php?id=158815

最近编辑记录 ljj_jjl2008 (2012-06-18 17:25:25)

离线

#2 2012-06-18 20:12:20

reverland
root
注册时间: 2012-02-04
帖子: 356
个人网站

Re: 来寻求帮助了,关于makefile文件的。特别是Arch用户,和“贱兔”用户,请进。

不懂帮顶


>>>>>>>>>jekyll博客>>>>>>>>>>
<<<<<<<<<更残念的vimwiki<<<<<<<<<
本人vim控,偏偏喜欢lisp

离线

#3 2012-06-18 20:44:21

YeLee
BOT
注册时间: 2011-08-19
帖子: 661

Re: 来寻求帮助了,关于makefile文件的。特别是Arch用户,和“贱兔”用户,请进。

Gentoo,不叫贱兔,请规范读音。


小白路过,大家给点面子!

离线

#4 2012-06-18 21:39:15

枫叶饭团
免费会员
所在地: C.C.
注册时间: 2011-08-27
帖子: 190
个人网站

Re: 来寻求帮助了,关于makefile文件的。特别是Arch用户,和“贱兔”用户,请进。

YeLee 说:

Gentoo,不叫贱兔,请规范读音。

就叫贱兔了。。。

离线

#5 2012-06-18 21:40:38

jtshs256
论坛版主
注册时间: 2011-08-19
帖子: 294

Re: 来寻求帮助了,关于makefile文件的。特别是Arch用户,和“贱兔”用户,请进。

枫叶饭团 说:
YeLee 说:

Gentoo,不叫贱兔,请规范读音。

就叫贱兔了。。。

离线

#6 2012-06-18 22:08:11

reverland
root
注册时间: 2012-02-04
帖子: 356
个人网站

Re: 来寻求帮助了,关于makefile文件的。特别是Arch用户,和“贱兔”用户,请进。

目测ls都是来歪楼的……


>>>>>>>>>jekyll博客>>>>>>>>>>
<<<<<<<<<更残念的vimwiki<<<<<<<<<
本人vim控,偏偏喜欢lisp

离线

#7 2012-06-19 09:17:15

自由建客
穷若韩信
所在地: 桂林市第六人民医院
注册时间: 2011-08-27
帖子: 250
个人网站

Re: 来寻求帮助了,关于makefile文件的。特别是Arch用户,和“贱兔”用户,请进。

jtshs256 说:
枫叶饭团 说:
YeLee 说:

Gentoo,不叫贱兔,请规范读音。

就叫贱兔了。。。

「贱兔」好啊就是好!

离线

#8 2012-06-19 18:16:09

phoenixlzx
晩ご飯だよー
注册时间: 2011-08-19
帖子: 1,789
个人网站

Re: 来寻求帮助了,关于makefile文件的。特别是Arch用户,和“贱兔”用户,请进。

表示不懂贱兔,但是目测ls也都是来歪楼的。

去找一份简单的源代码来看看结构吧~

离线

#9 2012-06-22 16:12:15

cjxgm
忙,却还想养猫?
所在地: 杭州
注册时间: 2011-08-19
帖子: 414
个人网站

Re: 来寻求帮助了,关于makefile文件的。特别是Arch用户,和“贱兔”用户,请进。

很多时候不需要 autotools 的,那东西又慢又麻烦,而且有很多好的替代品。
我一般都是手写 makefile,偶尔用 SConstruct 或自己的编译系统(cjbs,未公开)

PKGBUILD 和 makefile 没有直接关系的,不管你用什么编译系统来编译都可以用 PKGBUILD 来打包。不过我没学过怎么写。
另外,makefile 那样写不觉得很蹩脚吗?LZ还是应该多看看书

CC = gcc        # 看文件后缀明明是C语言的为什么要用C++编译器?
CCFLAGS = -lX11 -lImlib2 -lXmu `pkg-config --cflags --libs glib-2.0`

.PHONY: icon-wharf clean install uninstall

icon-wharf: bin/icon-wharf bin/iconrun1 bin/icon-desk    # ... ...

bin/icon-wharf: src/icon-wharf.c
bin/iconrun1: src/iconrun1.c

# ... ...

# 几个特殊的另外写
bin/icon-desk: src/icon-desk.c
	$(CXX) -o ./bin/icon-desk ./src/icon-desk.c -lXinerama -lXft  -lX11 -lImlib2 -lXmu  `pkg-config --cflags --libs glib-2.0` `giblib-config --cflags --libs` -lcurl -lpng -lXcomposite -lXdamage -lXfixes -lXrender  -lm


clean:
	@rm -f ./bin/*

install 我不会用,等别人来回答吧

离线

#10 2012-06-22 21:16:03

ljj_jjl2008
会员
注册时间: 2012-06-02
帖子: 33

Re: 来寻求帮助了,关于makefile文件的。特别是Arch用户,和“贱兔”用户,请进。

楼上:
我的程序,源代码一开始是抄袭别人的,是c。
后来为了增加功能,又抄袭了一部分c++的代码进去,但是文件名不愿意改了。因为里面有些语句c不能编译,只能用c++编译,所以只好用g++作为编译器了。
我尝试过clang、gcc、g++、cc等多个编译器,只有g++编译出来的最完美。

最近编辑记录 ljj_jjl2008 (2012-06-22 21:16:28)

离线

#11 2012-06-22 21:21:23

cjxgm
忙,却还想养猫?
所在地: 杭州
注册时间: 2011-08-19
帖子: 414
个人网站

Re: 来寻求帮助了,关于makefile文件的。特别是Arch用户,和“贱兔”用户,请进。

那你最好把文件名后缀改成 .cc 或 .C (大写)或 .cxx 或 .cpp,这样才可以正确套用 makefile 默认规则
然后:

CXX = g++
CXXFLAGS = -lX11 -lImlib2 -lXmu `pkg-config --cflags --libs glib-2.0`

离线

页脚