Results 1 to 5 of 5

Thread: Need Help Writing Makefile.am

  1. #1
    Join Date
    Aug 2007
    Location
    NY, United States
    Beans
    169
    Distro
    Ubuntu 11.04 Natty Narwhal

    Need Help Writing Makefile.am

    I'm trying to GNUify a package that I want to distribute.

    Because I can't figure out Makefiles, I write a quick bash file that does the compiling for me. So I tried to read over the documentation for Automake... And I find it rather confusing.

    So, how do I convert this...
    Code:
    #!/bin/bash
    
    gcc $(pkg-config --cflags --libs libpanelapplet-2.0 libwnck-1.0) -o taskdock-applet taskdock.c
    sudo cp taskdock-applet /usr/lib/gnome-panel
    sudo cp TaskdockApplet_Factory.server /usr/lib/bonobo/servers
    ...into a Makefile.am?

    Note: After pkg-config is run, the data expands to...
    Code:
    #!/bin/bash
    
    gcc -DORBIT2=1 -pthread -I/usr/include/panel-2.0 -I/usr/include/gtk-2.0 -I/usr/include/libgnomeui-2.0 -I/usr/include/libbonoboui-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/libart-2.0 -I/usr/include/gconf/2 -I/usr/include/gnome-keyring-1 -I/usr/include/libgnome-2.0 -I/usr/include/libgnomecanvas-2.0 -I/usr/include/gnome-vfs-2.0 -I/usr/lib/gnome-vfs-2.0/include -I/usr/include/orbit-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/libbonobo-2.0 -I/usr/include/bonobo-activation-2.0 -I/usr/include/libxml2 -I/usr/include/gail-1.0 -I/usr/include/libwnck-1.0 -I/usr/include/startup-notification-1.0  -pthread -lpanel-applet-2 -lgnomeui-2 -lSM -lICE -lbonoboui-2 -lgnomevfs-2 -lgconf-2 -lgnomecanvas-2 -lgnome-2 -lpopt -lart_lgpl_2 -lbonobo-2 -lbonobo-activation -lORBit-2 -lgthread-2.0 -lrt -lwnck-1 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lgio-2.0 -lcairo -lpango-1.0 -lfreetype -lz -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -o taskdock-applet taskdock.c
    sudo cp taskdock-applet /usr/lib/gnome-panel
    sudo cp TaskdockApplet_Factory.server /usr/lib/bonobo/servers
    I figured out that the -I fields get attached to an INCLUDES variable, like so:
    Code:
    INCLUDES = -I/usr/include/panel-2.0 -I/usr/include/gtk-2.0 -I/usr/include/libgnomeui-2.0 -I/usr/include/libbonoboui-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/libart-2.0 -I/usr/include/gconf/2 -I/usr/include/gnome-keyring-1 -I/usr/include/libgnome-2.0 -I/usr/include/libgnomecanvas-2.0 -I/usr/include/gnome-vfs-2.0 -I/usr/lib/gnome-vfs-2.0/include -I/usr/include/orbit-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/libbonobo-2.0 -I/usr/include/bonobo-activation-2.0 -I/usr/include/libxml2 -I/usr/include/gail-1.0 -I/usr/include/libwnck-1.0 -I/usr/include/startup-notification-1.0
    But the rest I don't know about.
    Acer Aspire 5050-5554 w/ 4GB RAM upgrade. Ubuntu Aug 07 - Dec 08; Arch Linux Dec 08 - July 2011; Ubuntu again since July 2011.
    "Triclops": Home-built AMD Athlon II X2 250, 4GB RAM, Radeon 6570, 500GB HDD. Ubuntu/Windows-XP duo since Jun 2010.

  2. #2
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,274
    Distro
    Kubuntu

    Re: Need Help Writing Makefile.am

    I also do not know anything about AutoMake. Makefiles on the other hand, are easy to put together.

    Here's a Makefile that should work, but since I do not have the packages libpanelappley-2.0 nor libwnck-1.0 on my system, I could not test it.

    Be careful if you copy/paste the example below. Tab-spaces need to be preserved.

    Code:
    APPNAME  = taskdock-applet
    SERVER   = TaskdockApplet_Factor.server
    
    SRCS     = taskdock.c
    DEST1    = /usr/lib/gnome-panel
    DEST2    = /usr/lib/bonobo/servers
    
    CFLAGS   = -Wall -pedantic `pkg-config --cflags libpanelapplet-2.0 libwnck-1.0`
    LIBS     = `pkg-config --libs libpanelapplet-2.0 libwnck-1.0`
    
    OBJS     = $(SRCS:.c=.o)
    DEP_FILE = .depend
    
    .PHONY: all clean distclean
    
    
    all: depend $(APPNAME)
    
    install: all
            @echo Installing $(APPNAME) and $(SERVER)
            @install -m 755 $(APPNAME) $(DEST1)
            @install -m 755 $(SERVER) $(DEST2)
    
    $(APPNAME): $(OBJS)
            @echo Linking $@
            @$(CC) $^ $(LIBS) -o $@
    
    .c.o:
            @echo Compiling $<
            @$(CC) $(CFLAGS) -c $< -o $@
    
    clean:
            $(RM) $(OBJS)
            $(RM) $(APPNAME)
            $(RM) $(DEP_FILE)
    
    distclean: clean
            $(RM) $(DEST1)/$(APPNAME)
            $(RM) $(DEST2)/$(SERVER)
    
    depend: $(DEP_FILE)
            @touch $(DEP_FILE)
    
    $(DEP_FILE):
            @echo Building dependencies in: $@
            @$(CC) -E -MM $(CFLAGS) $(SRCS) >> $(DEP_FILE)
    
    ifeq (,$(findstring clean,$(MAKECMDGOALS)))
    ifeq (,$(findstring distclean,$(MAKECMDGOALS)))
    -include $(DEP_FILE)
    endif
    endif

  3. #3
    Join Date
    Jul 2005
    Location
    Manitoba
    Beans
    118
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Need Help Writing Makefile.am

    If you are having trouble figuring out makefiles, or if you just wish there was a simpler way I would recommend trying out CMake.

    It's a makefile generation tool, similar to QMake (which is packaged with QT) that gives you the strength of using makefiles without any of the headache.

    I believe that CMake is in the repos.

  4. #4
    Join Date
    Aug 2007
    Location
    NY, United States
    Beans
    169
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Need Help Writing Makefile.am

    Thanks, dwhitney67. It seems to be working fine. Hopefully I should be able to learn from this file as well.

    Also, thanks Luggy. I'll check out CMake when I get a chance.
    Acer Aspire 5050-5554 w/ 4GB RAM upgrade. Ubuntu Aug 07 - Dec 08; Arch Linux Dec 08 - July 2011; Ubuntu again since July 2011.
    "Triclops": Home-built AMD Athlon II X2 250, 4GB RAM, Radeon 6570, 500GB HDD. Ubuntu/Windows-XP duo since Jun 2010.

  5. #5
    Join Date
    Apr 2005
    Beans
    849

    Re: Need Help Writing Makefile.am

    This thread might be outdated,
    I've spend a big part of my day trying to figure out how autoconf automake works. So anyone listening in might not waste half a day like i did

    Most of the documentation on the web is very outdated,
    and this is quite a problem since the innerworkings of autotool apparantly change overnight.

    So if you want the program to crosscompile with auto* this is how you should do it.

    Basicly you only need to create 3 files plus a README.

    Make a small file called README, make a subdir in this folder,
    copy your source files to this folder.
    Have a Makefile.am in both the src and the ../src

    The Makefile.am in src should look like
    PHP Code:
    bin_PROGRAMS taskdock-applet
    taskdock
    -applet_SOURCES taskdock.
    The Makefile in ../src should look like
    PHP Code:
    SUBDIRS src
    dist_doc_DATA 
    README 
    The last one is configure.ac, this can be autogenerated with autoscan, but don't bother.

    This configure.ac in your ../src should look like

    Code:
    AC_INIT([taskdock-applet], [0.3], [contact@gnu.org])
    AM_INIT_AUTOMAKE([-Wall -Werror foreign])
    AC_PROG_CC
    AC_CONFIG_HEADERS([config.h])
    AC_CONFIG_FILES([
               Makefile
               src/Makefile
              ])
    AC_OUTPUT
    
    AC_CHECK_LIB(libpanelapplet-2.0 libwnck-1.0,,echo "ERROR: Required library pcre++ not found" && exit)
    thats it now you generate all the needed files with
    autoreconf --install

    the --install flag tells the program to make default files of the files that are needed.

    now you can run
    ./configure
    make
    make install

    If you want to change the install dir you can use

    ./configure --prefix

    or for a complete list check
    ./configure --help
    Running 8.10 on a lenovo 3000 n200!
    Fingerprint reader doesn't work.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •